Sub Initialize
	'修改登录页form
	On Error Goto errhandle
	Dim session As notessession
	Dim db1 As notesdatabase
	Dim db2 As notesdatabase
	Dim nc As notesnotecollection
	Dim nc2 As notesnotecollection
	Dim stream As notesstream
	Dim exporter As NotesDXLExporter 
	Dim importer As notesdxlimporter
	Dim importer0 As notesdxlimporter
	Dim form As NotesForm 
	Dim nid As String 
	
	Dim file1 As String 
	Dim file2 As String 
	Dim file3 As String
	Dim outputFile As String
	
	Dim timeStr As String 
	
	Dim inputStream As NotesStream, outputStream As NotesStream
	Dim domParser As NotesDOMParser
	Dim docNode As NotesDOMDocumentNode
	Dim docRootNode As NotesDOMNode
	
	file1 = ""
	file2 = ""
	file3 = ""
	flag = False
	timeStr = Replace(Replace(Replace(Cstr(Now),"-",""),":","")," ","")
	
	Set session = New notessession
	Set db1 = session.currentdatabase
 '先判断当前服务器是否有登录库
	Set db2 = New NotesDatabase(db1.Server, "domcfg.nsf")
 '如果没有登录库
	If Not db2.IsOpen Then
		Set db2 = db1.CreateFromTemplate(db1.Server,"domcfg.nsf", True)
	Else
		Set form = db2.GetForm("$$LoginUserForm")
  '如果存在登录页，首先备份登录页''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		If Not form Is Nothing Then
			Set nc = db2.createnotecollection(False)
			Call nc.buildcollection
			Set nc2 = db2.createnotecollection(False)
			nc2.SelectForms = True
			Call nc2.BuildCollection 
			nid = nc2.GetFirstNoteId 
   '查找登录页表单
			Forall f In db2.Forms
				If Not f.IsSubForm Then
					If f.name = "$$LoginUserForm" Then
						nc.Add(nid)
						Exit Forall
					End If
					nid = nc2.GetNextNoteId(nid)
				End If
			End Forall
   '将表单导成dxl文件，并存在临时文件夹中
			Set stream = session.CreateStream
			file2 = "c:\temp\login_back_" & timeStr & "1.dxl"
			Call stream.Open(file2)
			Set exporter=session.createDXLexporter(nc, stream)
			Call exporter.process
			Call stream.close
   '删除原有登录页
			Call form.Remove
   '读取刚才的dxl文件（xml格式的文件），修改登录页名称
			file3 = "c:\temp\login_back_" & timeStr & "2.dxl"
			Set session = New NotesSession
			Set outputStream =session.CreateStream
			outputStream.Open(file3)
			Set inputStream = session.CreateStream
			inputStream.Open (file2)
			If inputStream.Bytes > 0 Then
				Set domParser=session.CreateDOMParser(inputStream)
				Call domParser.Process
				Set docNode = domParser.Document
				Set docRootNode = docNode.DocumentElement
				If Not docRootNode.IsNull Then
     '修改文件中form节点的下属节点name的nodevalue的值
					Call ChangeNode(docRootNode,timeStr)
					Call domParser.setoutput(outputStream)
					Call domParser.Serialize 
				End If
			End If
   '导入备份登录页
			Set importer0=session.createdxlimporter(outputStream, db2)
			importer0.designimportoption = 2
			Call importer0.process
			Set importer0 = Nothing
			Call outputStream.Truncate 
			Call inputStream.Truncate 
			Call outputStream.Close 
			Call inputStream.Close 
		End If
		
  '导入登录页'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		Set nc = db1.createnotecollection(False)
		Call nc.buildcollection
		Set nc2 = db1.createnotecollection(False)
		nc2.SelectForms = True
		Call nc2.BuildCollection 
		nid = nc2.GetFirstNoteId
  '取得当前库的登录页表单
		Forall f In db1.Forms
			If Not f.IsSubForm Then
				If f.name = "$$LoginUserForm" Then
					nc.Add(nid)
					Exit Forall
				End If
				nid = nc2.GetNextNoteId(nid)
			End If
		End Forall
  '导成dxl文件，并存在临时文件夹中
		Set stream = session.CreateStream
		file1 = "c:\temp\login_" & timeStr & ".dxl"
		Call stream.Open(file1)
  '把dxl导入到domcfg库中
		Set exporter=session.createDXLexporter(nc, stream)
		Set importer=session.createdxlimporter(stream, db2)
		importer.designimportoption = 2 
		Call exporter.process
		Call importer.process
		Call stream.Truncate 
		Call stream.close
	End If
	
	Exit Sub
errhandle:
	Msgbox Cstr(Erl) & "  " & Error
End Sub